package com.xbongbong.pro.enums.fund.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 在线支付流水类型枚举
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
public enum OnlinePaymentFlowTypeEnum {

    /**
     * 1、订单支付
     * 经销商单笔订单的支付流水
     */
    ORDER_PAY("1", "enum.onlinePaymentFlowType.name.order_pay", "enum.onlinePaymentFlowType.distributorName.order_pay"),
    /**
     * 2、预收款充值
     * 经销商预收款充值的支付流水
     */
    PRE_RECHARGE("2", "enum.onlinePaymentFlowType.name.pre_recharge", "enum.onlinePaymentFlowType.distributorName.pre_recharge"),
    /**
     * 3、支付货款
     * 经销商通过待付款付款的支付流水
     */
    PAYMENT_PAY("3", "enum.onlinePaymentFlowType.name.payment_pay", "enum.onlinePaymentFlowType.distributorName.payment_pay"),

    /**
     * 4、订单退款
     * 经销商在线支付的退款的支付流水
     */
    REFUND_ONLINE("4", "enum.onlinePaymentFlowType.name.refund_online", "enum.onlinePaymentFlowType.distributorName.refund_online"),
    ;

    /**
     * code
     */
    private String code;

    /**
     * 厂商端名称
     */
    private String name;

    /**
     * 经销商端名称
     */
    private String distributorName;


    OnlinePaymentFlowTypeEnum(String code, String name, String distributorName){
        this.code = code;
        this.name = name;
        this.distributorName = distributorName;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getI18nName() {
        return name;
    }

    /**
     * 根据code获取枚举
     * @param code
     * @return com.xbongbong.pro.enums.fund.enums.OnlinePaymentFlowTypeEnum
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static OnlinePaymentFlowTypeEnum getByCode(Integer code){
        for (OnlinePaymentFlowTypeEnum cache : values()) {
            if (Objects.equals(cache.code, code)) {
                return cache;
            }
        }
        return null;
    }
}
